﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidateControl.aspx.cs" Inherits="ValidateControls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1 {
            height: 30px;
        }
    </style>
    <script type="text/javascript">
        function testFullname (source, args) {
            args.IsValid = true;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width: 100%;">
            <tr>
                <td style="width: 200px">
                    &nbsp;</td>
                <td>
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                </td>
            </tr>
            <tr>
                <td style="width: 200px">
                    Username <span style="color: red">*</span>
                </td>
                <td>
                    <asp:TextBox ID="userNameText" runat="server" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="userNameText" ErrorMessage="Phải điền tên đăng nhập"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Họ tên <span style="color: red">*</span>
                </td>
                <td>
                    <asp:TextBox ID="fullNameText" runat="server" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="fullNameText" ErrorMessage="Phải điền họ tên"></asp:RequiredFieldValidator>
                &nbsp;<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="testFullname" ControlToValidate="fullNameText" ErrorMessage="Họ tên quá ngắn" onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Email</td>
                <td>
                    <asp:TextBox ID="emailText" runat="server" Width="200px"></asp:TextBox>
                    <%--\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* --%>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="emailText" ErrorMessage="Phải điền email"></asp:RequiredFieldValidator>
                &nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="emailText" ErrorMessage="Email không hợp lệ" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Mật khẩu <span style="color: red">*</span>
                </td>
                <td>
                    <asp:TextBox ID="passwordText" runat="server" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="passwordText" ErrorMessage="Phải điền mật khẩu"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Nhập lại mật khẩu <span style="color: red">*</span>
                </td>
                <td>
                    <asp:TextBox ID="repasswordText" runat="server" Width="200px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="fullNameText" ErrorMessage="Phải nhập lại mật khẩu"></asp:RequiredFieldValidator>
                &nbsp;<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="passwordText" ControlToValidate="repasswordText" Display="Dynamic" ErrorMessage="Mật khẩu không khớp"></asp:CompareValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Ngày sinh
                </td>
                <td>
                    <asp:TextBox ID="birthDayText" runat="server" Width="200px"></asp:TextBox>
                    <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="birthDayText" ErrorMessage="Bạn không đủ 18" MaximumValue="1994/10/25" MinimumValue="1900/1/1" Type="Date"></asp:RangeValidator>
                </td>
            </tr>
            <tr>
                <td class="style1">
                </td>
                <td class="style1">
                    <asp:Button ID="Button1" runat="server" Text="Đăng ký" onclick="Button1_Click" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
